<!--suppress ALL -->
<include file="./Template/header.html" />
<link rel="stylesheet" type="text/css" href="/Template/css/messagebox.css?v=2">
<script type="text/javascript">


    $(function() {

        //初始化页面配置
        initPage("咨询");

        var app = new Vue({
            el: '#container',
            data: {
                info: [],
            },
            methods: {

                index: indexPage,
                checkRole: function(employeeRoleId, roleId) {
                    var employeeRoleArr = employeeRoleId.split(",");
                    var roleArr = roleId.split(",");

                    var result = false;
                    $.each(roleArr, function(i,val){
                        if($.inArray(val, employeeRoleArr) != -1 || $.inArray((parseInt(val)+100).toString(), employeeRoleArr) != -1){
                            result = true;
                        }
                    });
                    return result;
                },
                cancel: function() {
                    window.location.href = "/wechat";
                },
                copyText: function() {
                    var input = document.getElementById("copy");
                    input.select();
                    document.execCommand("copy");
                    alert("微信号复制成功");
                },
                submit: function() {

                    var messageId = $("input[name=messageId]").val();
                    var employeeId = $("select[name=employeeId]").val();
                    if(isNullOrEmpty(employeeId)) {
                        alert("请选择要通知的员工");
                        return false;
                    }

                    $(".save-btn").hide();

                    $.ajax({
                        url:"/wechat/Messagebox/notify",
                        type:"post",
                        data:{
                            messageId: messageId,
                            employeeId: employeeId,
                        },

                        dataType:"JSON",
                        beforeSend:function(){
                            $("#loadingToast").show();
                        },
                        complete:function(){
                            $('#loadingToast').hide();
                        },
                        success:function(data){
                            if(data.code == 200) {
                                alert("提交成功");
                                window.location.href = "/wechat/";
                            }
                        },
                    })

                }

            }
        })

        $(".item select").change(function() {
            var value = $(this).find("option:selected").text();
            $(this).prev().val(value);
        });

        $("input[type=date]").change(function() {
            var value = $(this).val();
            $(this).prev().val(value);
        });

    });


</script>
<div class="edit-content">
    <input type="text" style="display: none;" name="messageId" value="{$messagebox.messagebox_id}">
    <input type="text" style="display: none;" name="customerId" value="{$customerId}">
    <div class="item" v-if="checkRole('{$role}', '1,3')">
        <span>通知给</span>
        <input id="employeeId" type="text" name="employeeName" value="" readonly placeholder="请选择">
        <select name="employeeId">
            <option value="">请选择通知人员</option>
            {:getEmployeeSelectOptionHtml($user['enterprise_code'],0)}
        </select>
        <img class="icon-right disease" src="/Template/images/icon-right.png" alt="">
        <p class="address" v-if="'{$messagebox.notified}' != ''" >
            已通知：{$messagebox.notified}
        </p>
    </div>
    <!--<div class="item">-->
        <!--<p class="address">已通知：{$messagebox.notified}</p>-->
    <!--</div>-->
    <div class="item">
        <span>用户昵称</span>
        <input type="text" name="nickname" value="{$customer.nickname}" placeholder="请填写">
        <img class="icon-right" src="/Template/images/icon-right.png" alt="">
    </div>
    <div class="item">
        <span>留言时间</span>
        <input type="text" name="createTime" value="{$messagebox.create_time}" readonly>
        <img class="icon-right" src="/Template/images/icon-right.png" alt="">
    </div>
    <!--div class="item" v-if="'{$customer.doctor_name}' != ''" >
        <span>所属医生</span>
        <input type="text" name="doctor" value="{$customer.doctor_name}" placeholder="请填写">
        <img class="icon-right" src="/Template/images/icon-right.png" alt="">
    </div>
    <div class="item" v-if="'{$customer.hospital_name}' != ''" >
        <span>所属医院</span>
        <input type="text" name="hospital" value="{$customer.hospital_name}" placeholder="请填写">
        <img class="icon-right" src="/Template/images/icon-right.png" alt="">
    </div-->
    <div class="item">
        <span>姓名</span>
        <input type="text" name="fullname" value="{$messagebox.fullname}" placeholder="请填写您的姓名">
        <img class="icon-right" src="/Template/images/icon-right.png" alt="">
    </div>
    <div class="item">
        <span>联系电话</span>
        <input type="text" name="number" value="{$messagebox.number}" placeholder="请填写您的电话号码">
        <img class="icon-right" src="/Template/images/icon-right.png" alt="">
    </div>
    <div class="item">
        <span>企业或机构名</span>
        <input type="text" name="enterprise" value="{$messagebox.enterprise}" placeholder="请填写您的企业或机构名">
        <img class="icon-right" src="/Template/images/icon-right.png" alt="">
    </div>
    <div style="height: 8rem;line-height: 2.5rem" class="item" id="productCheck">
        <span>业务产品：</span>
        <br/>
        <label class="checkbox inline">
            <php>
                $listArr = explode(",",$messagebox["product_list"]);
                $nameArr = array("上肢矫形器","下肢矫形器","脊柱矫形器","假肢","成品销售","其它");
                $check = array();
                for($i = 0;$i < 7;$i++){
                $check[$i] = in_array($nameArr[$i],$listArr)?"checked":"";
                }
            </php>
            <input class="checkItem" type="checkbox" name="上肢矫形器" {$check.0}>上肢矫形器&nbsp;&nbsp;&nbsp;&nbsp;
            <input class="checkItem" type="checkbox" name="下肢矫形器" {$check.1}>下肢矫形器&nbsp;&nbsp;&nbsp;&nbsp;
            <input class="checkItem" type="checkbox" name="脊柱矫形器" {$check.2}>脊柱矫形器
            <br/>
            <input class="checkItem" type="checkbox" name="假肢" {$check.3}>假肢&nbsp;&nbsp;&nbsp;&nbsp;
            <input class="checkItem" type="checkbox" name="成品销售" {$check.4}>成品销售&nbsp;&nbsp;&nbsp;&nbsp;
            <input class="checkItem" type="checkbox" name="其它" {$check.5}>其它
        </label>
    </div>
    <div class="title-span">
        <span>功能需求</span>
    </div>
    <div class="area">
        <textarea class="t-area" name="messageContent" placeholder="请填写您的功能需求">{$messagebox.message_content}</textarea>
    </div>
    <div class="title-span">
        <span>其它</span>
    </div>
    <div class="area">
        <textarea class="t-area" name="note" placeholder="请填您的其他留言">{$messagebox.note}</textarea>
    </div>
</div>

<div class="operation-btn">
    <div class="cancel-btn" v-on:click="cancel">取消</div>
    <div class="save-btn" v-on:click="submit" v-if="checkRole('{$role}', '1,3')">提交</div>
</div>
<include file="./Template/footer.html" />

